<template>
  <div class="wrape-content">
    <div class="top">
      <img src="../../assets/user-image/location.png" alt="位置">
      <span>您当前所在的位置：短信服务/群发管理</span>
    </div>
    <div class="content">
      <div class="form">
        <el-form
          :model="ruleForm"
          :rules="rules"
          ref="ruleForm"
          label-width="80px"
          class="ruleForm"
        >
          <el-form-item label="发送人" prop="send_peopel">
            <el-input v-model="ruleForm.send_peopel" placeholder="请输入发布人姓名"></el-input>
          </el-form-item>
          <el-form-item label="发送日期" prop="send_time">
            <el-date-picker
              v-model="ruleForm.send_time"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择发送日期"
            ></el-date-picker>
          </el-form-item>

          <el-form-item>
            <section class="oprtionbtn">
              <el-button type="primary" class="feicuilu" size="small" @click="getMessageData">查询</el-button>
              <el-button size="small" @click="resetForm('ruleForm')">重置</el-button>
            </section>
          </el-form-item>
        </el-form>

        <section class="opreation">
          <el-button type="primary" class="feicuilu addbtn" @click="addMessaeg">
            <img src="../../assets/add.png">新增群发
          </el-button>
        </section>
      </div>
      <div class="Table">
        <el-table
          style="width:98%;margin:0 auto"
          show-overflow-tooltip
          :height="height"
          border
          @selection-change="handleSelectionChange"
          :data="tableData"
        >
          <el-table-column align="center" type="selection" width="55"></el-table-column>
          <el-table-column
            v-for="(item,index) in tableHeaderData"
            show-overflow-tooltip
            :key="index"
            :prop="item.prop"
            :label="item.label"
            align="center"
          ></el-table-column>
          <el-table-column label="操作" align="center" width="100">
            <template slot-scope="scope">
              <div class="actionbtn" style="background:#24B3B3">
                <img @click="upDataTec(scope.row)" src="../../assets/details.png" title="查看">
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <el-dialog class="Notic" :visible.sync="AddDialog" :title="edititle" width="60%">
      <span style="font-size:17px;color:#041f41">
        <b>基本信息:</b>
      </span>
      <div class="from">
        <el-form
          :model="NoticruleForm"
          :rules="noticrules"
          ref="NoticruleForm"
          label-width="140px"
          class="NoticruleForm"
        >
          <el-form-item label="联系人分组" prop="project_code">
            <el-select v-model="NoticruleForm.project_code" clearable placeholder="请选择所属模块">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="短信内容" prop="send_content">
            <el-input
              class="textarea"
              maxlength="500"
              type="textarea"
              v-model="NoticruleForm.send_content"
              placeholder="请输入群发短信内容"
            ></el-input>
            <span>{{L_content}}</span>
            <span style="color:red">/500(字数包括标点符号、空格和回车)</span>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="resetForm('NoticruleForm')">重置</el-button>
        <el-button type="primary" class="feicuilu" @click="submitForm('NoticruleForm')">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ruleForm: {},
      NoticruleForm: {},
      noticrules: {
        project_code: [
          { required: true, message: "请选择所属分组", trigger: "blur" }
        ],
        send_content: [
          { required: true, message: "短信内容不为空", trigger: "blur" }
        ]
      },
      edititle: "新增群发", // 还是查看
      rules: {},
      userid: [],
      AddDialog: false,
      L_content: "",
      options: [
        // 分组选项
        {
          label: "分组名称",
          value: "分组名称"
        }
      ],
      tableData: [
        {
          dataindex: 1
        }
      ],
      height: [],
      tableHeaderData: [
        {
          prop: "dataindex",
          label: "序号",
          width: "60"
        },
        {
          prop: "classname",
          label: "所属分组"
        },
        {
          prop: "name",
          label: "发送人"
        },
        {
          prop: "cellphone",
          label: "接收人"
        },
        {
          prop: "level",
          label: "发送日期"
        },
        {
          prop: "area_name",
          label: "短信内容"
        }
      ]
    };
  },
  updated() {
    try {
      this.L_content = this.NoticruleForm.send_content.length; // 文字字数
    } catch (error) {}
  },
  methods: {
    getMessageData() {
      // 查询短信
    },
    addMessaeg() {
      //
      this.AddDialog = true;
    },
    handleCommand(item) {
      console.log(item);
    },
    handleSelectionChange(value) {
      console.log(value);
      this.userid = value;
    },
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          console.log("验证通过");
          //   this.saveNotci();
        } else {
        }
      });
    },
    resetForm(formName) {
      // 重置查询的条件

      this.$refs[formName].resetFields();
    }
  },
  created() {
    this.height = window.screen.height - 225 + "px";
  }
};
</script>

<style lang="stylus" scoped>
.wrape-content {
  flex: 1;
  background: rgb(241, 242, 247);
  padding: 0% 1.1%;
}

.content {
  background: white;
  box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.05);
  padding-bottom: 40px;
}

.top {
  background: white;
  font-size: 13px;
  margin-bottom: 12px;
  color: #4D4D4D;
  box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.05);
  line-height: 35px;
  padding-left: 5px;

  span {
    margin-left: 5px;
  }
}

.form, .ruleForm >>> {
  .el-form-item__label-wrap {
    margin-left: 15px;
  }
}

.ruleForm {
  display: flex;
  flex-wrap: wrap;
  margin: 0 auto;

  .el-form-item {
    margin-bottom: 0px;
    margin-top: 9px;
    flex: 0 0 24%;
  }
}

.addbtn img, .exportbtn img, .deletebtn img {
  vertical-align: bottom !important;
}

.opreation {
  justify-self: start;
  margin-top: 10px;
  margin-left: 19px;
}

.Table {
  margin-top: 9px;
  border-top: 1px solid #E5E5E5;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.05);
}

.Table >>> {
  .el-table {
    margin-top: 10px !important;

    th {
      background-color: rgba(235, 240, 255, 1) !important;
      padding: 8px 0;
    }
  }
}

.Table >>> {
  .el-table__body-wrapper {
    td {
      padding: 7.5px;
    }
  }
}

.actionbtn {
  display: inline-block;
  width: 23px;
  height: 23px;
  padding: 2px 1px;
  margin-left: 5px;
  border-radius: 5px;
  cursor: pointer;
}

.Notic >>>.el-dialog__header {
  background: rgb(4, 31, 65);

  .el-dialog__title {
    color: white;
  }
}

.NoticruleForm {
  display: flex;
  margin-top: 30px;
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-left: 58px;

  .el-form-item {
    flex: 0 0 80%;
  }

  .el-select {
    display: block;
  }

  .el-cascader {
    display: block;
  }
}

.textarea >>> {
  .el-textarea__inner {
    height: 150px;
  }
}

.noativebtn {
  pointer-events: none;
  background: #66b1ff !important;
  border-color: #66b1ff !important;
  color: #FFF;
}
</style>